<div>
<ul id="role_tree"></ul>
</div>
<script type="text/javascript">
$('#role_tree').tree({
	method: 'get',
	lines:true,
	checkbox:true,
	width:200,
    url: JSmile.baseUrl+'/sys_role/findAll',
    loadFilter:function(data,parent){
    	return JSmile.convert(data,{textField:"roleName"});
    },
    onLoadSuccess:function(node, data){
    	var _userId='#(userId)';
    	var role_tree=$("#role_tree"); 
     	role_tree.tree("clearAllChecked");
       	JSmile.KHttp.send({
       		url:"/sys_role/getUserRole",
   		    data:{userId:_userId}}).done(function(res){
   				for(var i=0;i<res.resData.rows.length;i++){
   					var node = role_tree.tree('find', res.resData.rows[i].id);
   					role_tree.tree('check', node.target);
   				}
       	});
    }
});
</script>